package com.xy.servicemanage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.servicemanage.ServicesAll;
import com.xy.servicemanage.service.IServicesAllService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 全部服务Controller
 *
 * @author ruoyi
 * @date 2025-06-05
 */
@RestController
@RequestMapping("/all")
public class ServicesAllController extends BaseController
{
    @Autowired
    private IServicesAllService servicesAllService;

    /**
     * 查询全部服务列表
     */
    @RequiresPermissions("servicemanage:all:list")
    @GetMapping("/list")
    public TableDataInfo list(ServicesAll servicesAll)
    {
        startPage();
        List<ServicesAll> list = servicesAllService.selectServicesAllList(servicesAll);
        return getDataTable(list);
    }

    /**
     * 导出全部服务列表
     */
    @RequiresPermissions("servicemanage:all:export")
    @Log(title = "全部服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServicesAll servicesAll)
    {
        List<ServicesAll> list = servicesAllService.selectServicesAllList(servicesAll);
        ExcelUtil<ServicesAll> util = new ExcelUtil<ServicesAll>(ServicesAll.class);
        util.exportExcel(response, list, "全部服务数据");
    }

    /**
     * 获取全部服务详细信息
     */
    @RequiresPermissions("servicemanage:all:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(servicesAllService.selectServicesAllById(id));
    }

    /**
     * 新增全部服务
     */
    @RequiresPermissions("servicemanage:all:add")
    @Log(title = "全部服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServicesAll servicesAll)
    {
        return toAjax(servicesAllService.insertServicesAll(servicesAll));
    }

    /**
     * 修改全部服务
     */
    @RequiresPermissions("servicemanage:all:edit")
    @Log(title = "全部服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServicesAll servicesAll)
    {
        return toAjax(servicesAllService.updateServicesAll(servicesAll));
    }

    /**
     * 删除全部服务
     */
    @RequiresPermissions("servicemanage:all:remove")
    @Log(title = "全部服务", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(servicesAllService.deleteServicesAllById(id));
    }
}

